package top.hugo.generator.controller;


import cn.dev33.satoken.annotation.SaIgnore;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


import top.hugo.common.domain.R;
import top.hugo.common.utils.BeanCopyUtils;
import top.hugo.domain.TableDataInfo;
import top.hugo.generator.dto.TLimitBoardDto;
import top.hugo.generator.entity.TLimitBoard;
import top.hugo.generator.query.TLimitBoardQuery;
import top.hugo.generator.service.TLimitBoardService;
import top.hugo.generator.vo.TLimitBoardVo;

import java.util.Date;
import java.util.List;

/**
 * 集合竞价数据信息操作处理
 *
 * @author kuanghua
 * @since 2025-01-02 18:07:03
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/tLimitBoard")
@SaIgnore
public class TLimitBoardController {
    private final TLimitBoardService tLimitBoardService;

    /**
     * 获取tLimitBoard列表
     *
     * @return
     */
    //@SaCheckPermission("system:tLimitBoard:list")
    @PostMapping("/list")
    public TableDataInfo<TLimitBoardVo> list(@RequestBody @Validated TLimitBoardQuery tLimitBoard) {
        return tLimitBoardService.selectPageTLimitBoardList(tLimitBoard);
    }

    /**
     * 获取configSave列表(所有)
     *
     * @return
     */
    @GetMapping("/listPageAll")
    public R<List<TLimitBoard>> listPageAll(@Validated TLimitBoardQuery configSave) {
        List<TLimitBoard> tLimitBoards = tLimitBoardService.selectPageTLimitBoardAll(configSave);
        return R.ok(tLimitBoards);
    }

    /**
     * 根据tLimitBoard编号获取详细信息
     *
     * @param tLimitBoardId tLimitBoardID
     */

    @GetMapping(value = "/{tLimitBoardId}")
    public R<TLimitBoard> getInfo(@PathVariable Long tLimitBoardId) {
        return R.ok(tLimitBoardService.selectTLimitBoardById(tLimitBoardId));
    }

    /**
     * 新增tLimitBoard
     */
    @PostMapping
    public R<Void> add(@Validated @RequestBody TLimitBoardDto tLimitBoardDto) {
        TLimitBoard tLimitBoard = BeanCopyUtils.copy(tLimitBoardDto, TLimitBoard.class);
        return R.result(tLimitBoardService.insertTLimitBoard(tLimitBoard));
    }

    /**
     * 修改tLimitBoard
     */
    @PutMapping
    public R<Void> edit(@Validated @RequestBody TLimitBoardDto tLimitBoardDto) {
        TLimitBoard tLimitBoard = BeanCopyUtils.copy(tLimitBoardDto, TLimitBoard.class);
        return R.result(tLimitBoardService.updateTLimitBoard(tLimitBoard));
    }

    /**
     * 删除tLimitBoard
     *
     * @param Ids tLimitBoardID串
     */
//@Log(title = "tLimitBoard管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{Ids}")
    public R<Void> remove(@PathVariable Long[] Ids) {
        return R.result(tLimitBoardService.deleteTLimitBoardByIds(Ids));
    }

    /**
     * 获取tLimitBoard选择框列表
     */
    @GetMapping("/selectTLimitBoardAll")
    public R<List<TLimitBoardVo>> selectTLimitBoardAll() {
        List<TLimitBoardVo> tLimitBoards = tLimitBoardService.selectTLimitBoardAll();
        return R.ok(tLimitBoards);
    }


    /**
     * @param beginTime 开始时间
     * @param endTime 结束时间
     * @return
     */
    /*删除数据*/
    @SaIgnore
    //集合竞价接口
    @GetMapping("deleteTLimitBoardByDate")
    public int deleteTLimitBoardByDate(String beginTime,String endTime) {
        return tLimitBoardService.deleteTLimitBoardByDate(beginTime,endTime);
    }
}
